﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Web.Mvc;
using MvcApplication1.Utility;
using RIMS.Lib.Manager;
using RIMS.Lib.Models;

namespace MvcApplication1.Actions.EmployeeActions
{
    public class List : Common, IList
    {
//        private readonly IEmployeeManager _employeeManager;
//        public List(IEmployeeManager employeeManager)
//        {
//            _employeeManager = employeeManager;
//        }

        public Hashtable Execute(FormCollection collection)
        {
            Hashtable result = new Hashtable();
            //result[Tools.IS_ERROR] = true;
            try
            {
                InitPager(collection);
                IList<Employee> employees = new EmployeeManager().Paging(PAGE_NUMBER, RESULT_PER_PAGE);

                if (employees == null || employees.Count == 0)
                {
                    result[Tools.MESSAGE] = "Emplyee could not found";
                    return result;
                }

                FlexiGridObject gridObject = GetFlexiGridList(PAGE_NUMBER, 17, employees);
                result[Tools.PAGE] = gridObject.page;
                result[Tools.TOTAL] = gridObject.total;
                result[Tools.ROWS] = gridObject.rows;
                //esult[Tools.IS_ERROR] = false;
                return result;
            }
            catch (Exception ex)
            {

                return result;
            }
        }
    }
}